class index_UI extends egret.Sprite {

    public constructor() {
        super();
        this.once(egret.Event.ADDED_TO_STAGE, this.createView, this);
    }
    private createView() {
        //设置当前场景的锚点
        this.x=320;
        this.y=568;
        this.anchorOffsetX=320;
        this.anchorOffsetY=568;

        var shadow = createBitmap("shadow_png", -640, 300);  //运动员
        this.addChild(shadow);
        var swinMan = createBitmap("swinMan_png", -640, 340);//运动员的影子
        this.addChild(swinMan);

        var yz_logo = createBitmap("yz_logo_png", 400, 100);
        this.addChild(yz_logo);
        var index_aoyun = createBitmap("index_aoyun_png", 50, 100);
        this.addChild(index_aoyun);
        index_aoyun.visible = false;
        var index_zhijian = createBitmap("index_zhijian_png", 50, 278);
        this.addChild(index_zhijian);
        index_zhijian.visible = false;
        var index_ziyouyong = createBitmap("index_ziyouyong_png", 50, 400);
        this.addChild(index_ziyouyong);
        index_ziyouyong.visible = false;



        egret.Tween.get(swinMan).to({ x: 0, y: 200 }, 500)
        egret.Tween.get(shadow).to({ x: 0, y: 240 }, 550).call(function () {
            egret.Tween.get(index_aoyun).to({ visible: true }, 500).call(function () {
                egret.Tween.get(index_zhijian).to({ visible: true }, 500).call(function () {
                    egret.Tween.get(index_ziyouyong).to({ visible: true }, 500)
                }, this)
            }, this)
        }, this)

        //开始按钮
        var star_bnt = my_button("开始", 68, 0xfe3c63, true, 303, 120, 168, 873, "kaishi_btn_png", 6, 0xfff530);
        this.addChild(star_bnt);
        
        // 点击跳转-GameUI
        
        star_bnt.touchEnabled=true;
        star_bnt.addEventListener(egret.TouchEvent.TOUCH_END,function(){
            egret.Tween.get(this).to({scaleX:0,alpha:0},800).call(function(){
                this.stage.removeChild(this);
                Main.game_bl=true;
            }.bind(this));
            
            egret.Tween.get(Main.game).to({scaleX:1},800).call(function(){}.bind(this));

        },this)


        //游戏规则
        var rule = createTextFiled("游戏规则", 0, 1040, 30, 0xffffff, "center", 640, 100, "middle");
        rule.bold = true;
        rule.fontFamily = "Microsoft JhengHei";
        this.addChild(rule);
        rule.touchEnabled = true;
        //游戏规则弹窗
        var rule_mask = drawReactShape(null, 63, 63, 516, 1020, 0x000000);
        rule_mask.alpha = 0.8;
        var rule_text = createBitmap("rule_text_png",100,130);
        var rongqi2 = new egret.DisplayObjectContainer;
        this.addChild(rongqi2);
        rongqi2.addChild(rule_mask);
        rongqi2.addChild(rule_text);
        rongqi2.anchorOffsetX  = 320;
        rongqi2.anchorOffsetY = 568;
        rongqi2.x  = rongqi2.width * .5+63;
        rongqi2.y = rongqi2.height * .5+90;
        rongqi2.scaleX = 0;
        rongqi2.touchEnabled = true;

        rule.addEventListener(egret.TouchEvent.TOUCH_TAP, function () {
              egret.Tween.get(rongqi2).to({ scaleX:1 }, 500);
        }, this);
        rongqi2.addEventListener(egret.TouchEvent.TOUCH_TAP, function () {
              egret.Tween.get(rongqi2).to({ scaleX:0 }, 500);
        }, this);
    }
}